package com.ymatou.iapi.sellerquery.testcase;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.sellerquery.parameter.GetOrderSalesRefundFlowsBean;
import com.ymatou.iapi.sellerquery.parameter.enums.SalesRefundStatusEnum;
import com.ymatou.iapi.sellerquery.parameter.resp.RefundFlowsResp;
import com.ymatou.iapi.sellerquery.service.GetOrderSalesRefundFlowsCall;
import com.ymatou.iapi.trading.operate.parameter.ActivityVo;
import com.ymatou.iapi.trading.operate.parameter.OrderGroupVo;
import com.ymatou.iapi.trading.operate.parameter.OrderItemVo;
import com.ymatou.iapi.trading.operate.parameter.OrderVo;
import com.ymatou.iapi.trading.operate.parameter.SellerCouponVo;
import com.ymatou.iapi.trading.operate.parameter.YmatouCouponVo;
import com.ymatou.iapi.trading.operate.parameter.enums.ActivityPromotionTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.AppTerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.PriceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.ProductRefundChannelEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SalesTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SellerCouponApplianceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.TerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.YmatouCouponApplianceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.trading.operate.parameter.req.SalesRefundSuccessRequestBean;
import com.ymatou.iapi.trading.operate.service.PlaceOrderCall;
import com.ymatou.iapi.trading.operate.service.SalesRefundSuccessRequestCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponCallService;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.ProductCallService;
import com.ymttest.database.model.YmtRefundBill;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.YmtRefundWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;
/**
*获取订单退货退款信息
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetOrderSalesRefundFlows{
	private static GetOrderSalesRefundFlowsBean getordersalesrefundflowsBean;
	private static GetOrderSalesRefundFlowsCall getordersalesrefundflowsCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取订单退货退款信息");
	}

	@Before
	public void caseUp() {
		getordersalesrefundflowsBean=new GetOrderSalesRefundFlowsBean();
		getordersalesrefundflowsCall=new GetOrderSalesRefundFlowsCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getordersalesrefundflowsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	   // 一个订单下面多个商品
    private Map placeOrder() {
        Map map = new HashMap();
        try {
            PlaceOrderReq placeorderBean = new PlaceOrderReq();
            PlaceOrderCall placeorderCall = new PlaceOrderCall();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            // 创建产品
            Logger.comment("前置数据准备");
            HashMap<String, Object> productInfo = ProductCallService
                    .createProduct(sellerId, 3);
            Logger.comment("前置数据准备结束");
            String productId = (String) productInfo.get("productId");
            Logger.debug("productId:" + productId);
            String productName = (String) productInfo.get("productName");
            String pic = (String) productInfo.get("pic");
            BigDecimal price = (BigDecimal) (productInfo.get("price"));
            String catalogId = (String) productInfo.get("catalogId");
            YmatouCouponVo ymtCoupon = new YmatouCouponVo();
            // 平台优惠券
            BigDecimal couponValue = new BigDecimal(13);
            String couponCode = new OrderCallService().receivePlatformCoupon(userId, couponValue);
            ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
            ymtCoupon.setCouponCode(couponCode);
            ymtCoupon.setCouponValue(couponValue);
            placeorderBean.setAppId("AutoTest");
            placeorderBean.setYmatouCoupon(ymtCoupon);
            placeorderBean.setUserId(userId);
            placeorderBean.setRequestId(TestDataManager.getRandomUUID()
                    .toString());
            placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
            placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
            placeorderBean.setSourceIp("127.0.0.1");
            placeorderBean.setAppId("ios");
            placeorderBean.setDeviceId("7777777777888888888888999");
            OrderGroupVo groupVo1 = new OrderGroupVo();
            placeorderBean.setOrderSource(OrderSourceEnum.PC);
            // 商家优惠券
            BigDecimal sellerCouponValue = new BigDecimal(15);
            String sellerCouponCode = new CouponCallService().receiveCouponInfo(sellerId, userId,
                    couponValue);
            SellerCouponVo sellerCoupon = new SellerCouponVo();
            sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
            sellerCoupon.setCouponCode(sellerCouponCode);
            sellerCoupon.setCouponValue(sellerCouponValue);
            groupVo1.setSellerCoupon(sellerCoupon);
            groupVo1.setSellerId(sellerId);
            List<OrderVo> orders = new ArrayList<OrderVo>();
            OrderVo ordervo1 = new OrderVo();
            ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
            ordervo1.setOrderType(OrderTypeEnum.Spot);
            ordervo1.setPaidFull(true);
            ordervo1.setAddress("上海市闸北区灵石路636号");
            ordervo1.setLeaveWord("ymt autotest");
            ordervo1.setPhone("13100000001");
            ordervo1.setPostCode("200001");
            ordervo1.setTelephone("021-51002100");
            ordervo1.setReceiveName("李四");
            List<OrderItemVo> items = new ArrayList<OrderItemVo>();
            OrderItemVo orderitem1 = new OrderItemVo();
            orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
            orderitem1.setProductNum(3);
            orderitem1.setProductName(productName);
            orderitem1.setPriceType(PriceTypeEnum.VipPrice);
            orderitem1.setProductId(TestDataManager.getRandomUUID().toString());
            price = new BigDecimal(210);
            orderitem1.setEarnestPrice(price);
            orderitem1.setProductPrice(price);
            orderitem1.setOriginalPrice(price);
            orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
            orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
            orderitem1.setProductRefundChannel(ProductRefundChannelEnum.Official);
            orderitem1.setBrandId(5);
            orderitem1.setPackageNo("11111111");
            orderitem1.setFirstCategoryId(111111111);
            orderitem1.setSecondCategoryId(22222222);
            orderitem1.setThirdCategoryId(3333333);
            orderitem1
                    .setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
            orderitem1.setProductRecordNo("1234567");
            orderitem1.setProductRefundChannel(ProductRefundChannelEnum.Official);
            orderitem1
                    .setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
            ActivityVo activity = new ActivityVo();
            activity.setActivityId(46870);
            activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10, "yyyy-MM-dd'T'HH:mm:ss"));
            activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10, "yyyy-MM-dd'T'HH:mm:ss"));
            activity.setActivityTemplateId(12345678);
            activity.setCommissionRate(new BigDecimal(1.1));
            activity.setCost(true);
            activity.setFeeFree(false);
            activity.setPremium(new BigDecimal(1.5));
            activity.setPromotionPrice(new BigDecimal(15));
            activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
            activity.setUseCoupon(true);
            orderitem1.setActivity(activity);
            ordervo1.setOrderItems(items);
            ordervo1.setFreight(new BigDecimal("21"));
            // 第2件商品
            OrderItemVo orderitem2 = new OrderItemVo();
            orderitem2.setCatalogId(TestDataManager.getRandomUUID().toString());
            orderitem2.setProductNum(1);
            orderitem2.setProductName(productName);
            orderitem2.setPriceType(PriceTypeEnum.VipPrice);
            orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
            price = new BigDecimal(270);
            orderitem2.setEarnestPrice(price);
            orderitem2.setProductPrice(price);
            orderitem2.setOriginalPrice(price);
            orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
            orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
            orderitem2.setProductRefundChannel(ProductRefundChannelEnum.Official);
            orderitem2.setBrandId(5);
            orderitem2.setPackageNo("11111111");
            orderitem2.setFirstCategoryId(111111111);
            orderitem2.setSecondCategoryId(22222222);
            orderitem2.setThirdCategoryId(3333333);
            orderitem2
                    .setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
            orderitem2.setProductRecordNo("1234567");
            orderitem2.setProductRefundChannel(ProductRefundChannelEnum.Official);
            orderitem2
                    .setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
            orderitem2.setActivity(activity);
            items.add(orderitem1);
            items.add(orderitem2);
            ordervo1.setOrderItems(items);
            ordervo1.setFreight(new BigDecimal("21"));
            orders.add(ordervo1);
            groupVo1.setOrders(orders);
            placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
            placeorderCall.setData(false, placeorderBean);
            placeorderCall.callService();
            JSONArray orderIds = placeorderCall.getOrderIds();
            int tradingId = placeorderCall.getTradingId();
            map.put("orderIds", orderIds);
            map.put("tradingId", tradingId);
        } catch (Exception e) {
            Logger.fail(e);
        }
        return map;
    }
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetOrderSalesRefundFlows_001() {
		Logger.start(true,"一个订单,多次退货退款,获取订单退货退款信息");
		try {
            OrderCallService orderCallService = new OrderCallService();
            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
            Map map = placeOrder();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            JSONArray orderIds = (JSONArray) map.get("orderIds");
            int tradingId = (Integer) map.get("tradingId");
            int orderId = orderIds.getInt(0);
            // 付款金额
            DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
            BigDecimal amount = orderCallService.getNeedPrePayAmountOfCash(orderId);
            // 付款
            orderCallService.orderPayRequest(userId, amount, tradingId);
            // 卖家接单
            orderCallService.acceptOrder(orderId, sellerId);
            // 申请退款
            orderCallService.applySalesRefundRequestInJava(orderId);
            salesrefundsuccessrequestBean.setOperatorInfo("autotest");
            salesrefundsuccessrequestBean.setOrderId(orderId);
            salesrefundsuccessrequestBean.setRefundBillNo("YMTTK0" + orderId);
            salesrefundsuccessrequestCall.setData(false,salesrefundsuccessrequestBean);
            Logger.comment("退该订单号" + orderId + "第一件商品");
            salesrefundsuccessrequestCall.callService();
            Logger.verifyEquals("ok", salesrefundsuccessrequestCall.getReturnData(), "验证退货退款成功返回");
            salesrefundsuccessrequestBean.setOrderId(orderId);
            salesrefundsuccessrequestBean.setRefundBillNo("YMTTK1" + orderId);
            salesrefundsuccessrequestCall.setData(false,salesrefundsuccessrequestBean);
            Logger.comment("退该订单号" + orderId + "第二件商品");
            salesrefundsuccessrequestCall.callService();       
			List<Integer> refundStatusList=new ArrayList<>();
			refundStatusList.add(SalesRefundStatusEnum.Success.getCode());
			refundStatusList.add(SalesRefundStatusEnum.Fail.getCode());
			refundStatusList.add(SalesRefundStatusEnum.Processing.getCode());
			getordersalesrefundflowsBean.setOrderId(orderId);
			getordersalesrefundflowsBean.setStatus(refundStatusList);
			getordersalesrefundflowsCall.setData(getordersalesrefundflowsBean);
			getordersalesrefundflowsCall.callService();			
            DefaultWapper defaultWapper = new DefaultWapper();
            // ymtOrderState 表
            List<Map> ymtOrderState = defaultWapper.selectOrderStateByOderId(orderId);
            // 订单主表
            List<Map> ymtOrders =defaultWapper.selectOrderByOderId(orderId);              
            YmtRefundWapper ymtRefund = new YmtRefundWapper();
            Map m = new HashMap();
            m.put("orderId", orderId);
            // 订单退货记录
            List<YmtRefundBill> refundBill = ymtRefund.selectRefundBill(m);
            
            BigDecimal orderTotal=(BigDecimal)ymtOrders.get(0).get("fTotalPrice");
            BigDecimal orderFreight=(BigDecimal)ymtOrders.get(0).get("fFreight");
            BigDecimal orderCash=((BigDecimal)ymtOrderState.get(0).get("fPaidAmountOfCash")).add((BigDecimal)ymtOrderState.get(0).get("fPostPaidAmountOfCash"));
            BigDecimal orderGift=((BigDecimal)ymtOrderState.get(0).get("fPaidAmountOfGift")).add((BigDecimal)ymtOrderState.get(0).get("fPostPaidAmountOfGift"));
            BigDecimal orderCoupon=(BigDecimal)ymtOrderState.get(0).get("fPaidAmountOfYmtCoupon");
            BigDecimal orderSellerCoupon=(BigDecimal)ymtOrderState.get(0).get("fPaidAmountOfSellerCoupon");

            BigDecimal refundTotal=refundBill.stream().map( YmtRefundBill->YmtRefundBill.getRefundAmount()).reduce(BigDecimal::add).get();
            BigDecimal refundCash=refundBill.stream().map( YmtRefundBill->YmtRefundBill.getRefundedAmountOfCash()).reduce(BigDecimal::add).get();
            BigDecimal refundGift=refundBill.stream().map( YmtRefundBill->YmtRefundBill.getRefundedAmountOfGift()).reduce(BigDecimal::add).get();
            BigDecimal refundCoupon=refundBill.stream().map( YmtRefundBill->YmtRefundBill.getSettlementAmountOfCoupon()).reduce(BigDecimal::add).get();
                        
			RefundFlowsResp orderResp=getordersalesrefundflowsCall.getRefundFlowsResp("order");
			RefundFlowsResp refundResp=getordersalesrefundflowsCall.getRefundFlowsResp("refund");
			
			Logger.verifyEquals(ECode.SUCCESS, getordersalesrefundflowsCall.getCode(), "验证code");
			Logger.verifyEquals(0, getordersalesrefundflowsCall.getBCode(), "验证bcode");
			Logger.verifyEquals(true, getordersalesrefundflowsCall.getData().getBoolean("success"), "验证success");

			Logger.verifyEquals(orderTotal, orderResp.getTotal(), "验证total");
			Logger.verifyEquals(orderCash, orderResp.getCash(), "验证cash");
			Logger.verifyEquals(orderGift, orderResp.getGift(), "验证gift");
			Logger.verifyEquals(orderCoupon, orderResp.getCoupon(), "验证coupon");
			Logger.verifyEquals(orderSellerCoupon, orderResp.getSellerCoupon(), "验证sellerCoupon");
			Logger.verifyEquals(orderFreight, orderResp.getFreight(), "验证freight");
			
			Logger.verifyEquals(refundTotal, refundResp.getTotal(), "验证refund total");
			Logger.verifyEquals(refundCash, refundResp.getCash(), "验证refund cash");
			Logger.verifyEquals(refundGift, refundResp.getGift(), "验证refund gift");
			Logger.verifyEquals(refundCoupon, refundResp.getCoupon(), "验证refund coupon");
			Logger.verifyEquals(BigDecimal.ZERO.setScale(2), refundResp.getSellerCoupon(), "验证refund sellerCoupon");
			Logger.verifyEquals(BigDecimal.ZERO.setScale(2), refundResp.getFreight(), "验证refund freight");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetOrderSalesRefundFlows_002() {
		Logger.start(true,"一个订单,多次退货退款,订单退款状态为null,获取订单退货退款信息");
		try {
            OrderCallService orderCallService = new OrderCallService();
            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
            Map map = placeOrder();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            JSONArray orderIds = (JSONArray) map.get("orderIds");
            int tradingId = (Integer) map.get("tradingId");
            int orderId = orderIds.getInt(0);
            // 付款金额
            DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
            BigDecimal amount = orderCallService.getNeedPrePayAmountOfCash(orderId);
            // 付款
            orderCallService.orderPayRequest(userId, amount, tradingId);
            // 卖家接单
            orderCallService.acceptOrder(orderId, sellerId);
            // 申请退款
            orderCallService.applySalesRefundRequestInJava(orderId);
            salesrefundsuccessrequestBean.setOperatorInfo("autotest");
            salesrefundsuccessrequestBean.setOrderId(orderId);
            salesrefundsuccessrequestBean.setRefundBillNo("YMTTK0" + orderId);
            salesrefundsuccessrequestCall.setData(false,salesrefundsuccessrequestBean);
            Logger.comment("退该订单号" + orderId + "第一件商品");
            salesrefundsuccessrequestCall.callService();
            Logger.verifyEquals("ok", salesrefundsuccessrequestCall.getReturnData(), "验证退货退款成功返回");
            salesrefundsuccessrequestBean.setOrderId(orderId);
            salesrefundsuccessrequestBean.setRefundBillNo("YMTTK1" + orderId);
            salesrefundsuccessrequestCall.setData(false,salesrefundsuccessrequestBean);
            Logger.comment("退该订单号" + orderId + "第二件商品");
            salesrefundsuccessrequestCall.callService();       
			List<Integer> refundStatusList=new ArrayList<>();
/*			refundStatusList.add(SalesRefundStatusEnum.Success.getCode());
			refundStatusList.add(SalesRefundStatusEnum.Fail.getCode());
			refundStatusList.add(SalesRefundStatusEnum.Processing.getCode());*/
			
			getordersalesrefundflowsBean.setOrderId(orderId);
			getordersalesrefundflowsBean.setStatus(refundStatusList);
			getordersalesrefundflowsCall.setData(getordersalesrefundflowsBean);
			getordersalesrefundflowsCall.callService();			
            DefaultWapper defaultWapper = new DefaultWapper();
            // ymtOrderState 表
            List<Map> ymtOrderState = defaultWapper.selectOrderStateByOderId(orderId);
            // 订单主表
            List<Map> ymtOrders =defaultWapper.selectOrderByOderId(orderId);              
            YmtRefundWapper ymtRefund = new YmtRefundWapper();
            Map m = new HashMap();
            m.put("orderId", orderId);
            // 订单退货记录
            List<YmtRefundBill> refundBill = ymtRefund.selectRefundBill(m);
            
            BigDecimal orderTotal=(BigDecimal)ymtOrders.get(0).get("fTotalPrice");
            BigDecimal orderFreight=(BigDecimal)ymtOrders.get(0).get("fFreight");
            BigDecimal orderCash=((BigDecimal)ymtOrderState.get(0).get("fPaidAmountOfCash")).add((BigDecimal)ymtOrderState.get(0).get("fPostPaidAmountOfCash"));
            BigDecimal orderGift=((BigDecimal)ymtOrderState.get(0).get("fPaidAmountOfGift")).add((BigDecimal)ymtOrderState.get(0).get("fPostPaidAmountOfGift"));
            BigDecimal orderCoupon=(BigDecimal)ymtOrderState.get(0).get("fPaidAmountOfYmtCoupon");
            BigDecimal orderSellerCoupon=(BigDecimal)ymtOrderState.get(0).get("fPaidAmountOfSellerCoupon");

            BigDecimal refundTotal=refundBill.stream().map( YmtRefundBill->YmtRefundBill.getRefundAmount()).reduce(BigDecimal::add).get();
            BigDecimal refundCash=refundBill.stream().map( YmtRefundBill->YmtRefundBill.getRefundedAmountOfCash()).reduce(BigDecimal::add).get();
            BigDecimal refundGift=refundBill.stream().map( YmtRefundBill->YmtRefundBill.getRefundedAmountOfGift()).reduce(BigDecimal::add).get();
            BigDecimal refundCoupon=refundBill.stream().map( YmtRefundBill->YmtRefundBill.getSettlementAmountOfCoupon()).reduce(BigDecimal::add).get();
                        
			RefundFlowsResp orderResp=getordersalesrefundflowsCall.getRefundFlowsResp("order");
			RefundFlowsResp refundResp=getordersalesrefundflowsCall.getRefundFlowsResp("refund");
			
			Logger.verifyEquals(ECode.SUCCESS, getordersalesrefundflowsCall.getCode(), "验证code");
			Logger.verifyEquals(0, getordersalesrefundflowsCall.getBCode(), "验证bcode");
			Logger.verifyEquals(true, getordersalesrefundflowsCall.getData().getBoolean("success"), "验证success");

			
			Logger.verifyEquals(orderTotal, orderResp.getTotal(), "验证total");
			Logger.verifyEquals(orderCash, orderResp.getCash(), "验证cash");
			Logger.verifyEquals(orderGift, orderResp.getGift(), "验证gift");
			Logger.verifyEquals(orderCoupon, orderResp.getCoupon(), "验证coupon");
			Logger.verifyEquals(orderSellerCoupon, orderResp.getSellerCoupon(), "验证sellerCoupon");
			Logger.verifyEquals(orderFreight, orderResp.getFreight(), "验证freight");
			
			Logger.verifyEquals(refundTotal, refundResp.getTotal(), "验证refund total");
			Logger.verifyEquals(refundCash, refundResp.getCash(), "验证refund cash");
			Logger.verifyEquals(refundGift, refundResp.getGift(), "验证refund gift");
			Logger.verifyEquals(refundCoupon, refundResp.getCoupon(), "验证refund coupon");
			Logger.verifyEquals(BigDecimal.ZERO.setScale(2), refundResp.getSellerCoupon(), "验证refund sellerCoupon");
			Logger.verifyEquals(BigDecimal.ZERO.setScale(2), refundResp.getFreight(), "验证refund freight");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetOrderSalesRefundFlows_003() {
		Logger.start(true,"该订单没有退款记录,获取订单退货退款信息");
		try {
            OrderCallService orderCallService = new OrderCallService();
            SalesRefundSuccessRequestBean salesrefundsuccessrequestBean=new SalesRefundSuccessRequestBean();
            SalesRefundSuccessRequestCall salesrefundsuccessrequestCall=new SalesRefundSuccessRequestCall();
            Map map = placeOrder();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            JSONArray orderIds = (JSONArray) map.get("orderIds");
            int tradingId = (Integer) map.get("tradingId");
            int orderId = orderIds.getInt(0);
          
			List<Integer> refundStatusList=new ArrayList<>();
			refundStatusList.add(SalesRefundStatusEnum.Success.getCode());
			refundStatusList.add(SalesRefundStatusEnum.Fail.getCode());
			refundStatusList.add(SalesRefundStatusEnum.Processing.getCode());
			
			getordersalesrefundflowsBean.setOrderId(orderId);
			getordersalesrefundflowsBean.setStatus(refundStatusList);
			getordersalesrefundflowsCall.setData(getordersalesrefundflowsBean);
			getordersalesrefundflowsCall.callService();			
         
			RefundFlowsResp orderResp=getordersalesrefundflowsCall.getRefundFlowsResp("order");
			RefundFlowsResp refundResp=getordersalesrefundflowsCall.getRefundFlowsResp("refund");
			
			Logger.verifyEquals(ECode.SUCCESS, getordersalesrefundflowsCall.getCode(), "验证code");
			Logger.verifyEquals(0, getordersalesrefundflowsCall.getBCode(), "验证bcode");
			Logger.verifyEquals(true, getordersalesrefundflowsCall.getData().getBoolean("success"), "验证success");
			
			Logger.verifyEquals(null, orderResp, "验证total");
			Logger.verifyEquals(null, refundResp, "验证cash");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetOrderSalesRefundFlows_004() {
		Logger.start(true,"订单号不存在,获取订单退货退款信息");
		try {
            int orderId = 1111;
          
			List<Integer> refundStatusList=new ArrayList<>();
			refundStatusList.add(SalesRefundStatusEnum.Success.getCode());
			refundStatusList.add(SalesRefundStatusEnum.Fail.getCode());
			refundStatusList.add(SalesRefundStatusEnum.Processing.getCode());
		
			getordersalesrefundflowsBean.setOrderId(orderId);
			getordersalesrefundflowsBean.setStatus(refundStatusList);
			getordersalesrefundflowsCall.setData(getordersalesrefundflowsBean);
			getordersalesrefundflowsCall.callService();			
         
			RefundFlowsResp orderResp=getordersalesrefundflowsCall.getRefundFlowsResp("order");
			RefundFlowsResp refundResp=getordersalesrefundflowsCall.getRefundFlowsResp("refund");
			
			Logger.verifyEquals(ECode.SUCCESS, getordersalesrefundflowsCall.getCode(), "验证code");
			Logger.verifyEquals(0, getordersalesrefundflowsCall.getBCode(), "验证bcode");
			Logger.verifyEquals(true, getordersalesrefundflowsCall.getData().getBoolean("success"), "验证success");
			
			Logger.verifyEquals(null, orderResp, "验证total");
			Logger.verifyEquals(null, refundResp, "验证cash");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_GetOrderSalesRefundFlows_005() {
		Logger.start(true,"订单号为null,获取订单退货退款信息");
		try {
            int orderId = 1111;
          
			List<Integer> refundStatusList=new ArrayList<>();
			refundStatusList.add(SalesRefundStatusEnum.Success.getCode());
			refundStatusList.add(SalesRefundStatusEnum.Fail.getCode());
			refundStatusList.add(SalesRefundStatusEnum.Processing.getCode());
		
			//getordersalesrefundflowsBean.setOrderId(orderId);
			getordersalesrefundflowsBean.setStatus(refundStatusList);
			getordersalesrefundflowsCall.setData(getordersalesrefundflowsBean);
			getordersalesrefundflowsCall.callService();			
         
			RefundFlowsResp orderResp=getordersalesrefundflowsCall.getRefundFlowsResp("order");
			RefundFlowsResp refundResp=getordersalesrefundflowsCall.getRefundFlowsResp("refund");
			
			Logger.verifyEquals(ECode.ERROR400, getordersalesrefundflowsCall.getCode(), "验证code");
			Logger.verifyEquals(100, getordersalesrefundflowsCall.getBCode(), "验证bcode");
			Logger.verifyEquals("orderId:订单号不能为0", getordersalesrefundflowsCall.getMsg(), "验证bcode");
			Logger.verifyEquals(false, getordersalesrefundflowsCall.getData().getBoolean("success"), "验证success");
			
			Logger.verifyEquals(null, orderResp, "验证total");
			Logger.verifyEquals(null, refundResp, "验证cash");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}